From addae982a5e1ec18389731cc22493040ff333081 Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Sat, 4 Nov 2017 14:36:44 -0600 Subject: [PATCH] add encoding test for travis builds. --- .travis.yml | 8 ++++++++ build_and_test | 2 ++ test_encoding | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100755 test_encoding diff --git a/.travis.yml b/.travis.yml index de45387ef..15f3858e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,14 @@ addons: - libusb-dev - docbook-xml - docbook-xsl +before_script: +# get locale needed for test_encoding. +# these commands seem to work on xenial +# - sudo sed -i 's/^# *\(en_US ISO-8859-1\)/\1/' /etc/locale.gen +# - sudo dpkg-reconfigure --frontend=noninteractive locales +# but on trusty it took something different, including eating an error from local-gen. + - sudo locale-gen en_US ISO-8859-1 || sudo locale-gen + - locale -a script: - ./build_and_test # TODO: build mac diff --git a/build_and_test b/build_and_test index 1f3918624..2c37da12b 100755 --- a/build_and_test +++ b/build_and_test @@ -31,6 +31,8 @@ make linux-gui make doc make gpsbabel.html make check +# test for mangled encoding of command line arguments +./test_encoding #make torture rm -f vg.log ./vtesto -l -j vg.log diff --git a/test_encoding b/test_encoding new file mode 100755 index 000000000..cabe47fa5 --- /dev/null +++ b/test_encoding @@ -0,0 +1,37 @@ +#!/bin/bash +# this file should be encoded in latin1 + +BASEPATH=`dirname $0` +PNAME=${PNAME:-${BASEPATH}/gpsbabel} +REFERENCE=${BASEPATH}/reference + +TMPDIR=${GBTEMP:-/tmp}/gpsbabel.$$ +mkdir -p $TMPDIR +trap "rm -fr $TMPDIR" 0 1 2 3 15 + +errorcount=0 + +if locale -a | grep -q en_US.iso88591 ; then + export LC_ALL=en_US.iso88591 + rm -f ${TMPDIR}/file*.kml + rm -f ${TMPDIR}/file*.gpx + +# test input file name mangling + cp ${REFERENCE}/bounds-test.gpx ${TMPDIR}/file¢.gpx + ${PNAME} -i gpx -f ${TMPDIR}/file¢.gpx -o kml -F ${TMPDIR}/fileo.kml || { + echo "ERROR: The input file name was mangled." + errorcount=`expr $errorcount + 1` + } + +# test output file name mangling + ${PNAME} -i gpx -f ${REFERENCE}/bounds-test.gpx -o kml -F ${TMPDIR}/file¢.kml + count=$(ls -1 -l ${TMPDIR}/file¢.kml | wc -l) + if [ $count -lt 1 ]; then + echo "ERROR: The output file name was mangled." + errorcount=`expr $errorcount + 1` + fi +else + echo "$0 cannot run without the en_US.iso88591 locale." +fi + +exit $errorcount -- 2.30.2